package com.ocom.payhandle.controller;


import com.alibaba.fastjson.JSON;
import com.ocom.common.entity.card.EntityXfRecord;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.payhandle.feign.XfRecordFeign;
import com.ocom.payhandle.fun.PayHandleFunService;
import com.ocom.payhandle.mq.business.saveorder.SaveOrderProductService;
import com.ocom.payhandle.service.XfRecordProcessExxxService;
import com.ocom.payhandle.service.XfRecordProcessService;
import com.ocom.payhandle.service.XfRepairpayConfigService;
import com.ocom.payhandle.service.XfUserparamConfigService;
import com.ocom.payhandle.vo.MqSaveOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class TestController {

    @Autowired
    XfRecordFeign xfRecordFeign;

    @Autowired
    private SaveOrderProductService saveOrderProductService;

    @Autowired
    private XfRecordProcessService xfRecordProcessService;

//    @GetMapping("/test123")
//    public Result chge(){
//
//        List<EntityXfRecordProcess> xfRecordProcessList =  xfRecordProcessService.testMqSpeed(52l);
//        List<EntityXfRecordProcess> xfRecordProcessList2 =  xfRecordProcessService.testMqSpeed(520l);
//        List<EntityXfRecordProcess> xfRecordProcessList3 =  xfRecordProcessService.testMqSpeed(650l);
//        List<EntityXfRecordProcess> xfRecordProcessList4 =  xfRecordProcessService.testMqSpeed(750l);
//
//        //新增成功表的退款数据
//        try {
//            for (int i = 1; i < xfRecordProcessList.size() + 1; i++) {
//                Random random = new Random();
//		        int randomNumber = random.nextInt(20);
//
//                EntityXfRecordProcess entityXfRecordProcess  = xfRecordProcessList.get(i);
//                MqSaveOrderVo mqSaveOrderVo = new MqSaveOrderVo();
//                mqSaveOrderVo.setComId(52l);
//                mqSaveOrderVo.setId(entityXfRecordProcess.getId());
//                mqSaveOrderVo.setMachNo(entityXfRecordProcess.getDeviceNo());
//
//
//                saveOrderProductService.saveOrder(mqSaveOrderVo);
//
//                EntityXfRecordProcess entityXfRecordProcess1  = xfRecordProcessList2.get(i);
//                MqSaveOrderVo mqSaveOrderVo1 = new MqSaveOrderVo();
//                mqSaveOrderVo1.setComId(520l);
//                mqSaveOrderVo1.setId(entityXfRecordProcess1.getId());
//                mqSaveOrderVo1.setMachNo(entityXfRecordProcess1.getDeviceNo());
//                saveOrderProductService.saveOrder(mqSaveOrderVo1);
//
//
//                EntityXfRecordProcess entityXfRecordProcess2 = xfRecordProcessList3.get(i);
//                MqSaveOrderVo mqSaveOrderVo2 = new MqSaveOrderVo();
//                mqSaveOrderVo2.setComId(650l);
//                mqSaveOrderVo2.setId(entityXfRecordProcess2.getId());
//                mqSaveOrderVo2.setMachNo(entityXfRecordProcess2.getDeviceNo());
//                saveOrderProductService.saveOrder(mqSaveOrderVo2);
//
//
//                EntityXfRecordProcess entityXfRecordProcess3  = xfRecordProcessList4.get(i);
//                MqSaveOrderVo mqSaveOrderVo3 = new MqSaveOrderVo();
//                mqSaveOrderVo3.setComId(750l);
//                mqSaveOrderVo3.setId(entityXfRecordProcess3.getId());
//                mqSaveOrderVo3.setMachNo(entityXfRecordProcess3.getDeviceNo());
//                saveOrderProductService.saveOrder(mqSaveOrderVo3);
//            }
//
//        } catch (Exception e) {
//            StackTraceElement ste = e.getStackTrace()[0];
//        }
//        return ResultUtil.success();
//    }


    @Autowired
    XfUserparamConfigService xfUserparamConfigService;

    @Autowired
    XfRepairpayConfigService xfRepairpayConfigService;

    @Autowired
    PayHandleFunService payHandleFunService;

    @GetMapping("/test1234")
    public Object chge4() throws InterruptedException {
        boolean bj = payHandleFunService.checkIfWaitPay(52l,"2",4l);
        return  bj;
    }

    @Autowired
    XfRecordProcessExxxService xfRecordProcessExxxService;

    @GetMapping("/test5678")
    public Result chge444() {

        EntityXfRecord entityXfRecord=new EntityXfRecord();
        entityXfRecord.setComId(52l);
        entityXfRecord.setPId(52l);
        entityXfRecord.setConsType(1);
        entityXfRecord.setConsTime(new Date());

        return  xfRecordProcessExxxService.timesManJian(52l,entityXfRecord);
    }


    @GetMapping("/test999")
    public Result chge4444() {

        EntityXfRecord entityXfRecord=new EntityXfRecord();
        entityXfRecord.setComId(52l);
        entityXfRecord.setPId(52l);
        entityXfRecord.setConsType(1);
        entityXfRecord.setMealNo("500");
        entityXfRecord.setConsTime(new Date());

        return  xfRecordProcessExxxService.times(52l,entityXfRecord);
    }




    @GetMapping("/test789")
    public Result chge544() {
        return ResultUtil.success( xfRecordProcessExxxService.selectTradeNo(159l,"DC00009f8768061620250401201518","00000000"));

    }

    @GetMapping("/test7890")
    public Result chge566() {
        return ResultUtil.success( xfRecordProcessExxxService.selectTradeNo(159l,51744091l));
    }


    @GetMapping("/test78907")
    public Result chge5665() {


        MqSaveOrderVo mqSaveOrderVo = new MqSaveOrderVo();
        mqSaveOrderVo.setComId(52l);
        mqSaveOrderVo.setId(51744092l);
        mqSaveOrderVo.setMachNo("23100102");
        mqSaveOrderVo.setType(2);
        saveOrderProductService.saveOrder(JSON.toJSONString(mqSaveOrderVo));

        return ResultUtil.success( );
    }



    @GetMapping("/test456")
    public Result chge464554() {
        int sun = xfRecordProcessExxxService.getUserPartCityCount(693l,new Date() , 155777l);
        return ResultUtil.success(sun);
    }

}
